package com.joinway.extension.socket.serializer;



/**
 * the byte was unsigned
 * @author Administrator
 *
 */
public class DualBytesIntegerSerializer implements ISegmentSerializer<Integer> {

	/**
	 * 
	 * @param data 按低字节到高字节顺序传递
	 * @return
	 */
	@Override
	public Integer deserialize(byte... bytes) {
		int low = 0x000000FF & bytes[0];
		int high = 0x000000FF & bytes[1];
		return (high << 8 | low);
	}

	@Override
	public byte[] serialize(Integer data) {
		return new byte[]{(byte)(0x000000FF & data), (byte)((0x0000FF00 & data) >> 8)};
	}

}
